package com.neusoft.elmboot.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CommonUtil {
    // 获取当前日期时间，格式为 "yyyy-MM-dd HH:mm:ss"
    public static String getCurrentDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(new Date());
    }

    // 将字符串日期转换为 java.util.Date
    public static Date parseDate(String dateStr) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            return formatter.parse(dateStr);
        } catch (ParseException e) {
            throw new RuntimeException("日期解析失败：" + dateStr, e);
        }
    }
}
